package com.hzhr.iot.statis.convertor.custom;

import com.hzhr.iot.statis.convertor.DeviceMonthlyGasConsumeConvertor;
import com.hzhr.iot.statis.entity.ext.DeviceCollectDeviceEntityExt;
import com.hzhr.iot.statis.entity.ext.DeviceMonthlyGasConsumeEntityExt;
import com.hzhr.iot.statis.model.deviceMonthlyGasConsume.DeviceMonthlyGasConsumeModel;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class DeviceMonthlyGasConsumeCustomConvertor extends DeviceMonthlyGasConsumeConvertor {
    @Override
    public DeviceMonthlyGasConsumeModel ext2deviceMonthlyGasConsumeModel(DeviceMonthlyGasConsumeEntityExt in) {
        DeviceMonthlyGasConsumeModel result = super.ext2deviceMonthlyGasConsumeModel(in);

        DeviceCollectDeviceEntityExt ext1 = in.getCollectDeviceExt();
        if (ext1 != null) {
            result.setCollectDeviceCategoryCode(ext1.getCategoryCode());
            result.setCollectDeviceResourceCode(ext1.getResourceCode());
            Date installTime = ext1.getInstallTime();
            if (installTime != null) {
                result.setCollectDeviceInstallTime(installTime.getTime());
            }
            result.setGasUserCode(ext1.getGasUserCode());
        }

        return result;
    }
}

